/**
 * Bamboo Software Organization
 * Java open source software.  
 */
package org.bamboo.easyejb.demo.client;

import junit.framework.TestCase;

import org.bamboo.easyejb.client.EJBConnection;
import org.bamboo.easyejb.client.EasyEJBConfigUtil;

/**
 * A client demo for testing invoke a pojo bean in a remote EJB container.
 * @author Ramond KK He, raymond.kk.he@gmail.com 
 * @version 1.0 
 * 2008-11-27  
 */
public class AdderClientDemo extends TestCase {
	public void testRemotePojo() {

		//test in jboss4.0.0
		//also can be tested with remote WAS, Weblogic etc.
		EJBConnection ejbConnection = new EJBConnection( EasyEJBConfigUtil.getInitialContextProperties() );	
		
		try {
			Object[] args = new Object[]{new Integer(30),new Integer(39)};
			Object result = ejbConnection.invokeRemotePojo("org.bamboo.easyejb.demo.calculator.pojo.Adder", "add",args );
			System.out.println("testRemotePojo result " + result);
			assertEquals("Add result ", 69, ((Integer)result).intValue());
		} catch (Exception e) {
			System.out.println("exception:" + e);
			fail(e.toString());
		}
	}
	
	public static void main(String[] args) {
//		TestRunner.run(AdderClientDemo.class);
		
		AdderClientDemo adderClientDemo = new AdderClientDemo();
		adderClientDemo.testRemotePojo();
	}
}
